package com.xiaoshuidi.cloud.module.contract.enums.contract;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author Feng
 * @date 2023/7/4
 */
@Getter
@AllArgsConstructor
public enum ContractApplyStatus {

    IN_REVIEW("1", "审批中"),

    EFFECTIVE("2", "已生效"),

    REJECTED("3", "已驳回"),

    CANCELED("4", "已取消"),

    TO_BE_EFFECTIVE("5", "待生效");

    private String code;
    private String msg;


    public static String getMsgByCode(String code) {
        if (code == null) {
            return "";
        }
        Optional<String> first = Arrays.stream(ContractApplyStatus.values()).filter(s -> s.getCode().equals(code)).map(s -> s.getMsg()).findFirst();
        if (first.isPresent()) {
            return first.get();
        }
        return "";
    }
}
